$.ajax({
	url: "https://order.wz1996.wang/wzbg/store/types",
	type: 'get',
	contentType: 'application/json',
	beforeSend: function(request) {
		request.setRequestHeader("token", localStorage.getItem("token"));
	},
	success: function(data) {
		console.log(data);
		if(data.code == "-1") {
			layar(data.msg);
			setTimeout("window.parent.frames.location.href='/xcxadmin/login.html'", 1000)
		}
	},
	error: function(e) {
		errcode(e);
	}
});
$(".delbox").draggable();
var table = $("#dataTables-example").DataTable({
	ajax: {
		url: "http://m.aidong.me:9999/gym/user/slave/stores/all",
		type: "get",
		beforeSend: function(request) {
			request.setRequestHeader("token", localStorage.getItem("token"));
		},
	},
	columns: [{
			data: "company_id"
		},
		{
			data: "name"
		},
		{
			data: "area",
			render: function(data, type, full) {
				return "<img class='citypic' src='../../../img/del.png' />"
			}
		},
		{
			data: "id",
			render: function(data, type, full) {
				return "<a href='single.html'>修改</a><a href='javascript:void(0);' style='margin-left:5px' class='deltel'>删除</a>"
			}
		}
	],
	responsive: false,
	bLengthChange: false,
	bSort: false,
	paging: true,
	bFilter: true,
	searching: false,
	bInfo: true,
	bAutoWidth: true,
	"oLanguage": {
		"sLengthMenu": "每页显示 _MENU_ 条记录",
		"sZeroRecords": "抱歉， 没有找到",
		"sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
		"sInfoEmpty": "没有数据",
		"sInfoFiltered": "(从 _MAX_ 条数据中检索)",
		"oPaginate": {
			"sFirst": "首页",
			"sPrevious": "前一页",
			"sNext": "后一页",
			"sLast": "尾页"
		},
		"sSearch": "查询条件:",
		"sZeroRecords": "没有检索到数据",
		"sProcessing": "<img src='./loading.gif' />"
	}
});
$("#dataTables-example").on('click', '.deltel', function() {
	$(".delbox").show();
	$(".bgc").show();
});
$(".cancel").on('click', function() {
	$(".delbox").hide();
	$(".bgc").hide();
});

Array.prototype.remove = function(val) {
	var index = this.indexOf(val);
	if(index > -1) {
		this.splice(index, 1);
	}
};
var citys = [];
$(".selcity").on('click', function() {
	if($(this).children('.pointer').hasClass('select')) {
		$(this).children('.pointer').removeClass('select');
		citys.remove($(this).children('.citytxt').html());
	} else {
		$(this).children('.pointer').addClass('select');
		citys.push($(this).children('.citytxt').html());
	}
	console.log(citys)
});

//会员卡照片
var img = document.getElementById("xmTanImg");

function xmTanUploadImg(obj) {
	var file = obj.files[0];
	var reader = new FileReader();
	//读取文件过程方法
	reader.onloadstart = function(e) {
		console.log("开始读取....");
	}
	reader.onprogress = function(e) {
		console.log("正在读取中....");
	}
	reader.onabort = function(e) {
		console.log("中断读取....");
	}
	reader.onerror = function(e) {
		console.log("读取异常....");
	}
	reader.onload = function(e) {
		console.log("成功读取....");
		img.src = e.target.result;
		// 保存会员照片
		localStorage.setItem("memberPhone", img.src);
		var icinmguuii = document.getElementsByClassName("ic-inmguuii")[0];
		icinmguuii.style.display = "block";
		//或者 img.src = this.result;  //e.target == this
	}
	reader.readAsDataURL(file)
}